package com.example.demo1.exception;

import com.example.demo1.common.AppResult;
import com.example.demo1.common.ResultCode;

public class ApplicationException extends RuntimeException{
    private final int code;

    public ApplicationException(String message) {
        super(message);
        this.code = ResultCode.INTERNAL_ERROR.getCode();
    }

    public ApplicationException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.code = resultCode.getCode();
    }

    public ApplicationException(ResultCode resultCode, String extraMessage) {
        super(resultCode.getMessage() + ": " + extraMessage);
        this.code = resultCode.getCode();
    }

    public int getCode() {
        return code;
    }
}
